package com.project.service.impl;

import com.project.mapper.SubSystemMapper;
import com.project.model.entity.SubSystem;
import com.project.service.SubSystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SubSystemServiceImpl implements SubSystemService {
    private final SubSystemMapper subSystemMapper;

    @Autowired
    public SubSystemServiceImpl(SubSystemMapper subSystemMapper) {
        this.subSystemMapper = subSystemMapper;
    }

    @Override
    public SubSystem addSubSystem(SubSystem subSystem) {
        subSystemMapper.insertSubSystem(subSystem);
        return subSystem;
    }

    @Override
    public void deleteSubSystem(Integer id) {
        subSystemMapper.deleteSubSystemById(id);
    }

    @Override
    public SubSystem updateSubSystem(SubSystem subSystem) {
        subSystemMapper.updateSubSystem(subSystem);
        return subSystem;
    }

    @Override
    public SubSystem getSubSystemById(Integer id) {
        return subSystemMapper.selectSubSystemById(id);
    }

    @Override
    public List<SubSystem> getAllSubSystems() {
        return subSystemMapper.selectAllSubSystems();
    }
    @Override
    public List<SubSystem> getSubSystemsByReportId(Integer reportId) {
        return subSystemMapper.selectSubSystemsByReportId(reportId);
    }

}
